<?php
	/**
	* Products Brands Get list 
	* return in Json format
	* For Category view page (not detail of category)
	* @author trungdt
	* @since Nov 8, 2011
	*/
	if (!defined('EXPONENT')) exit('');

	$brand_letter="A";
	if (isset($_REQUEST['brand']))
	{
		$brand_letter=_ab_safe_html_string($_REQUEST['brand']);
		$brand_letter=substr($brand_letter,0,1);
		if ($brand_letter == "")
			$brand_letter="A";
	}
	
	$data=$db->selectObjects("productsmodule_brand", "location_data = '".serialize($loc)."' AND UPPER(SUBSTRING(title,1,1)) = '{$brand_letter}'");
	foreach ($data as $k=>$v)
	{
		//Get the image file if there is one.
		if (isset($v->logo_id) && ($v->logo_id > 0)) {
			$file = $db->selectObject('file', 'id='.$v->logo_id);
			$v->logo_path = "/".$file->directory.'/'.$file->filename;
		}
		else
			$v->logo_path="";
	}
	
	$template=new template("productsmodule","_brand_getjson_forCategoryPage",$loc);
	$template->register_permissions(array('administrate',"configure"),$loc);
	$template->assign("brands", $data);
	$v=$template->render();
	echo $v;
	
	exponent_theme_setFlagAjaxAction(true);
?>